home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / layout / nsGrid.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  7KB  |  159 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2.  
  3. /* ***** BEGIN LICENSE BLOCK *****
  4.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.  *
  6.  * The contents of this file are subject to the Mozilla Public License Version
  7.  * 1.1 (the "License"); you may not use this file except in compliance with
  8.  * the License. You may obtain a copy of the License at
  9.  * http://www.mozilla.org/MPL/
  10.  *
  11.  * Software distributed under the License is distributed on an "AS IS" basis,
  12.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.  * for the specific language governing rights and limitations under the
  14.  * License.
  15.  *
  16.  * The Original Code is Mozilla Communicator client code.
  17.  *
  18.  * The Initial Developer of the Original Code is 
  19.  * Netscape Communications Corporation.
  20.  * Portions created by the Initial Developer are Copyright (C) 1998
  21.  * the Initial Developer. All Rights Reserved.
  22.  *
  23.  * Contributor(s):
  24.  *   Eric D Vaughan (original author)
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  28.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the MPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the MPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. #ifndef nsGrid_h___
  41. #define nsGrid_h___
  42.  
  43. #include "nsStackLayout.h"
  44. #include "nsIGridPart.h"
  45. #include "nsCOMPtr.h"
  46. #include "nsIFrame.h"
  47.  
  48. class nsGridRowGroupLayout;
  49. class nsGridRowLayout;
  50. class nsBoxLayoutState;
  51. class nsGridCell;
  52.  
  53. //#define DEBUG_grid 1
  54.  
  55. class nsGrid
  56. {
  57. public:
  58.   nsGrid();
  59.   ~nsGrid();
  60.  
  61.   nsGridRow* GetColumnAt(PRInt32 aIndex, PRBool aIsHorizontal = PR_TRUE);
  62.   nsGridRow* GetRowAt(PRInt32 aIndex, PRBool aIsHorizontal = PR_TRUE);
  63.   nsGridCell* GetCellAt(PRInt32 aX, PRInt32 aY);
  64.  
  65.   void NeedsRebuild(nsBoxLayoutState& aBoxLayoutState);
  66.   void RebuildIfNeeded();
  67.  
  68.   nsresult GetPrefRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsHorizontal = PR_TRUE);
  69.   nsresult GetMinRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsHorizontal = PR_TRUE);
  70.   nsresult GetMaxRowSize(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nsSize& aSize, PRBool aIsHorizontal = PR_TRUE);
  71.   nsresult GetRowFlex(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aSize, PRBool aIsHorizontal = PR_TRUE);
  72.  
  73.   nsresult GetPrefRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsHorizontal = PR_TRUE);
  74.   nsresult GetMinRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsHorizontal = PR_TRUE);
  75.   nsresult GetMaxRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, nscoord& aHeight, PRBool aIsHorizontal = PR_TRUE);
  76.   void GetRowOffsets(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aTop, nscoord& aBottom, PRBool aIsHorizontal = PR_TRUE);
  77.  
  78.   void RowChildIsDirty(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, PRInt32 aColumnIndex, PRBool aIsHorizontal = PR_TRUE);
  79.   void RowIsDirty(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsHorizontal = PR_TRUE);
  80.   void RowAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsHorizontal = PR_TRUE);
  81.   void CellAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, PRBool aIsHorizontal = PR_TRUE);
  82.   void DirtyRows(nsIBox* aRowBox, nsBoxLayoutState& aState);
  83. #ifdef DEBUG_grid
  84.   void PrintCellMap();
  85. #endif
  86.   PRInt32 GetExtraColumnCount(PRBool aIsHorizontal = PR_TRUE);
  87.   PRInt32 GetExtraRowCount(PRBool aIsHorizontal = PR_TRUE);
  88.  
  89. // accessors
  90.   void SetBox(nsIBox* aBox) { mBox = aBox; }
  91.   nsIBox* GetBox() { return mBox; }
  92.   nsIBox* GetRowBox() { return mRowBox; }
  93.   nsIBox* GetColumnBox() { return mColumnBox; }
  94.   nsGridRow* GetColumns();
  95.   nsGridRow* GetRows();
  96.   PRInt32 GetRowCount(PRInt32 aIsHorizontal = PR_TRUE);
  97.   PRInt32 GetColumnCount(PRInt32 aIsHorizontal = PR_TRUE);
  98.  
  99.   static nsIBox* GetScrolledBox(nsIBox* aChild);
  100.   static nsIBox* GetScrollBox(nsIBox* aChild);
  101.   void GetFirstAndLastRow(nsBoxLayoutState& aState, 
  102.                           PRInt32& aFirstIndex, 
  103.                           PRInt32& aLastIndex, 
  104.                           nsGridRow*& aFirstRow,
  105.                           nsGridRow*& aLastRow,
  106.                           PRBool aIsHorizontal);
  107.  
  108. private:
  109.   void GetPartFromBox(nsIBox* aBox, nsIGridPart** aPart);
  110.   void GetBoxTotalMargin(nsIBox* aBox, nsMargin& aMargin, PRBool aIsHorizontal = PR_TRUE);
  111.  
  112.   void FreeMap();
  113.   void FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns);
  114.   void BuildRows(nsIBox* aBox, PRBool aSize, nsGridRow** aColumnsRows, PRBool aIsHorizontal = PR_TRUE);
  115.   void BuildCellMap(PRInt32 aRows, PRInt32 aColumns, nsGridCell** aCells);
  116.   void PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, PRInt32 aRowCount, PRInt32 aColumnCount, PRBool aIsHorizontal = PR_TRUE);
  117.   void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
  118.   void SetLargestSize(nsSize& aSize, nscoord aHeight, PRBool aIsHorizontal = PR_TRUE);
  119.   void SetSmallestSize(nsSize& aSize, nscoord aHeight, PRBool aIsHorizontal = PR_TRUE);
  120.   PRBool IsGrid(nsIBox* aBox);
  121.  
  122.   // the box that implement the <grid> tag
  123.   nsIBox* mBox;
  124.  
  125.   // an array of row object
  126.   nsGridRow* mRows;
  127.  
  128.   // an array of columns objects.
  129.   nsGridRow* mColumns;
  130.  
  131.   // the first in the <grid> that implements the <rows> tag.
  132.   nsIBox* mRowBox;
  133.  
  134.   // the first in the <grid> that implements the <columns> tag.
  135.   nsIBox* mColumnBox;
  136.  
  137.   // a flag that is false tells us to rebuild the who grid
  138.   PRBool mNeedsRebuild;
  139.  
  140.   // number of rows and columns as defined by the XUL
  141.   PRInt32 mRowCount;
  142.   PRInt32 mColumnCount;
  143.  
  144.   // number of rows and columns that are implied but not 
  145.   // explicitly defined int he XUL
  146.   PRInt32 mExtraRowCount;
  147.   PRInt32 mExtraColumnCount;
  148.  
  149.   // x,y array of cells in the rows and columns
  150.   nsGridCell* mCellMap;
  151.  
  152.   // a flag that when true suppresses all other MarkDirties. This
  153.   // prevents lots of extra work being done.
  154.   PRBool mMarkingDirty;
  155. };
  156.  
  157. #endif
  158.  
  159.